#include <vector>
#include <iostream>

using namespace std;

class Solution 
{
public:
    int maxArea(vector<int>& height) 
    {
        int left = 0;
        int right = height.size() - 1;
        int maxVolumn = 0;
        while (left < right)
        {
            int volumn = (right - left) * min(height[left], height[right]);
            maxVolumn = max(volumn, maxVolumn);
            if(height[left] < height[right])
            {
                left++;
            }
            else
            {
                right--;
            }
        }
        return maxVolumn;
    }
};

int main() 
{
    Solution solution;
    
    // 测试案例1: [1,8,6,2,5,4,8,3,7]
    cout << "测试案例1:" << endl;
    vector<int> height1 = {1, 8, 6, 2, 5, 4, 8, 3, 7};
    cout << "输入: [1,8,6,2,5,4,8,3,7]" << endl;
    int result1 = solution.maxArea(height1);
    cout << "输出: " << result1 << endl;
    cout << "期望: 49 (索引1和8之间，高度min(8,7)=7，宽度8-1=7，面积=7*7=49)" << endl << endl;
    
    // 测试案例2: [1,1]
    cout << "测试案例2:" << endl;
    vector<int> height2 = {1, 1};
    cout << "输入: [1,1]" << endl;
    int result2 = solution.maxArea(height2);
    cout << "输出: " << result2 << endl;
    cout << "期望: 1 (高度min(1,1)=1，宽度1-0=1，面积=1*1=1)" << endl << endl;
    
    // 测试案例3: 单个元素
    cout << "测试案例3 (单个元素):" << endl;
    vector<int> height3 = {1};
    cout << "输入: [1]" << endl;
    int result3 = solution.maxArea(height3);
    cout << "输出: " << result3 << endl;
    cout << "期望: 0 (无法形成容器)" << endl << endl;
    
    // 测试案例4: 递增序列
    cout << "测试案例4 (递增序列):" << endl;
    vector<int> height4 = {1, 2, 3, 4, 5};
    cout << "输入: [1,2,3,4,5]" << endl;
    int result4 = solution.maxArea(height4);
    cout << "输出: " << result4 << endl;
    cout << "期望: 6 (索引0和4之间，高度min(1,5)=1，宽度4-0=4，面积=1*4=4；或索引1和4，高度min(2,5)=2，宽度3，面积=6)" << endl << endl;
    
    // 测试案例5: 递减序列
    cout << "测试案例5 (递减序列):" << endl;
    vector<int> height5 = {5, 4, 3, 2, 1};
    cout << "输入: [5,4,3,2,1]" << endl;
    int result5 = solution.maxArea(height5);
    cout << "输出: " << result5 << endl;
    cout << "期望: 6 (索引0和3之间，高度min(5,2)=2，宽度3-0=3，面积=2*3=6)" << endl << endl;
    
    // 测试案例6: 相同高度
    cout << "测试案例6 (相同高度):" << endl;
    vector<int> height6 = {3, 3, 3, 3, 3};
    cout << "输入: [3,3,3,3,3]" << endl;
    int result6 = solution.maxArea(height6);
    cout << "输出: " << result6 << endl;
    cout << "期望: 12 (索引0和4之间，高度min(3,3)=3，宽度4-0=4，面积=3*4=12)" << endl << endl;
    
    // 测试案例7: 大数值
    cout << "测试案例7 (大数值):" << endl;
    vector<int> height7 = {2, 1, 10, 1, 2};
    cout << "输入: [2,1,10,1,2]" << endl;
    int result7 = solution.maxArea(height7);
    cout << "输出: " << result7 << endl;
    cout << "期望: 8 (索引0和4之间，高度min(2,2)=2，宽度4-0=4，面积=2*4=8)" << endl << endl;
    
    // 测试案例8: 复杂情况
    cout << "测试案例8 (复杂情况):" << endl;
    vector<int> height8 = {1, 3, 2, 5, 25, 24, 5};
    cout << "输入: [1,3,2,5,25,24,5]" << endl;
    int result8 = solution.maxArea(height8);
    cout << "输出: " << result8 << endl;
    cout << "期望: 24 (索引4和5之间，高度min(25,24)=24，宽度5-4=1，面积=24*1=24)" << endl << endl;
    
    // 测试案例9: 空数组
    cout << "测试案例9 (空数组):" << endl;
    vector<int> height9 = {};
    cout << "输入: []" << endl;
    int result9 = solution.maxArea(height9);
    cout << "输出: " << result9 << endl;
    cout << "期望: 0 (空数组无法形成容器)" << endl << endl;
    
    return 0;
}